<!DOCTYPE html>
<html class="ui-page-login">
<head>
    <meta charset="utf-8"/>
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title></title>
    <script src="__PUBLIC__/js/jquery.min.js"></script>
    <script src="__PUBLIC__/home/plugins/layer/layer.js"></script>
    <script src="__PUBLIC__/mui/js/mui.min.js"></script>
    <script src="__PUBLIC__/js/angular.js"></script>
    <script src="__PUBLIC__/common.js"></script>
    <link rel="stylesheet" href="__PUBLIC__/mui/css/mui.css"/>
    <style>
        #member-login {
            display: none;
        }

        .area {
            margin: 20px auto 0px auto;
        }

        .mui-input-group {
            margin-top: 10px;
        }

        .mui-input-group:first-child {
            margin-top: 20px;
        }

        .mui-input-row label ~ input,
        .mui-input-row label ~ select,
        .mui-input-row label ~ textarea {
            width: 70%;
        }

        .mui-checkbox input[type=checkbox],
        .mui-radio input[type=radio] {
            top: 6px;
        }

        .mui-content-padded {
            margin-top: 25px;
        }

        .mui-btn {
            padding: 10px;
        }

        .link-area {
            display: block;
            margin-top: 25px;
            text-align: center;
        }

        .spliter {
            color: #bbb;
            padding: 0px 8px;
        }

        .oauth-area {
            position: absolute;
            bottom: 20px;
            left: 0px;
            text-align: center;
            width: 100%;
            padding: 0px;
            margin: 0px;
        }

        .oauth-area .oauth-btn {
            display: inline-block;
            width: 50px;
            height: 50px;
            background-size: 30px 30px;
            background-position: center center;
            background-repeat: no-repeat;
            margin: 0px 20px;
            /*-webkit-filter: grayscale(100%); */
            border: solid 1px #ddd;
            border-radius: 25px;
        }

        .oauth-area .oauth-btn:active {
            border: solid 1px #aaa;
        }

        .oauth-area .oauth-btn.disabled {
            background-color: #ddd;
        }

        .login-active {
            background: #f3363a;
        }

        .mui-input-group label {
            width: 70%;
            font-size: 15px;
            color: black;

        }

        .content {
            width: 30%;
            float: right;
            line-height: 40px;
            height: 40px;
            font-size: 13px;
            text-align: right;
            padding-right: 2%;

        }

        .go-item {
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            padding: 0;
            margin: 0;
            background: white;
            height: 60px;
            text-align: center;

        }

        #user-login .mui-input-row .time {
            width: 65%;
            color: black;
        }

        #user-login .mui-input-row .status {
            width: 35%;
            font-size: 14px;
            font-weight: bold;
            font-family: "Microsoft YaHei UI Light";

        }

        .mui-input-group .mui-input-row:nth-child(1) {
            border-top: 1px solid #c8c7cc;
        }

        .mui-input-group .mui-input-row:after {
            left: 0;
        }

        .mui-input-group .mui-input-row:nth-child(1):after {
            background: none;
        }

        .mui-input-group .mui-input-row:last-child:after {
            background: none;
        }

        #user-login .mui-input-group {
            margin-top: 0;
        }

        #withdraw {
            color: white;
            font-size: 16px;
            line-height: 44px;
            margin: 0;
            padding: 0;
            height: 44px;
        }

        #user-login .mui-input-group {
            background: #f6f6f6
        }

    </style>
    <link rel="stylesheet" href="__PUBLIC__/js/nice-validator-0.10.11/dist/jquery.validator.css"/>
    <script src="__PUBLIC__/js/nice-validator-0.10.11/dist/jquery.validator.js"></script>
    <script src="__PUBLIC__/js/nice-validator-0.10.11/dist/local/zh-CN.js"></script>
</head>
<body ng-app="myApp" ng-controller="Ctrl" ng-cloak>
<header class="mui-bar mui-bar-nav" style="background:#f3363a;">
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" style="color: white"></a>
    <h1 class="mui-title login-item" style="color: white">报单详情</h1>
</header>
<div class="mui-content">


    <div class="mui-input-group" style="margin-top: 3px">
        <div class="mui-input-row" style="background-color: lightgray;">
            <label class="time">我的库存</label>
        </div>
        <div class="mui-input-row" ng-repeat="kc in stock">
            <label>{{kc.name}}</label>
            <div class="content">
                {{kc.num}}
            </div>
        </div>
    </div>

    <div class="mui-input-group" style="margin-top: 3px">
        <div class="mui-input-row" style="background-color: lightgray;">

            <label>{{oorder.createtime}}</label>
            <div class="content" style="color:#ff6769">
                <div ng-show="oorder.status == 1">
                    待审核
                </div>
                <div ng-show="oorder.status == 2">
                    已驳回
                </div>
                <div ng-show="oorder.status == 3">
                    已审核
                </div>
                <div ng-show="oorder.status == 5">
                    已取消
                </div>
            </div>
        </div>
        <div class="mui-input-row">
            <label class="time">订单号：{{oorder.sn}}</label>
            <div class="content  ">
                总额：<span style="color:#ff6769">￥{{oorder.total}}</span>
            </div>
        </div>
        <div class="mui-input-row">
            <label>代理名称</label>
            <div class="content">
                {{agen.username}}
            </div>
        </div>
        <div class="mui-input-row">
            <label>代理</label>
            <div class="content">
                {{agen.account}}
            </div>
        </div>
        <div class="mui-input-row">
            <label>等级</label>
            <div class="content">
                {{agen.levelname}}代理
            </div>
        </div>

    </div>


    <div class="mui-input-row" style="background-color: lightgray;">
        <label class="time">报单详情</label>
    </div>
    <div class="mui-input-group" style="margin-top: 3px" ng-repeat="pro in detail">
        <div class="mui-input-row">
            <label>{{pro.name}}</label>
            <div class="content" style="color:#ff6769">
                <span ng-hide="pro.num*1 >= pro.boxnum*1">{{pro.num}}盒</span>
                <span ng-show="pro.num*1 >= pro.boxnum*1">{{floor(pro.num/pro.boxnum)}}箱{{pro.num%pro.boxnum}}盒</span>
            </div>
        </div>
        <div class="mui-input-row">
            <label>￥{{pro.price}}</label>
            <div class="content">
                小计：￥{{pro.total}}
            </div>
        </div>
    </div>
    <div class="mui-input-row" style="background:white">
        <button type="button"
                style="margin-right: 1em;text-align: center; padding: 5px 10px;height: 30px;margin-top: 5px;border-radius: 0;width: auto"
                class="mui-btn mui-btn-danger mui-btn-outlined"
                ng-show="oorder.rvstatus == 1 && oorder.status == 1 && oorder.rlevel - reviewagen.level > 0"
                ng-click="audit(viewid)">通过
        </button>
        <button type="button"
                style="margin-right: 1em;text-align: center; padding: 5px 10px;height: 30px;margin-top: 5px;border-radius: 0;width: auto"
                class="mui-btn mui-btn-danger mui-btn-outlined"
                ng-show="oorder.rvstatus == 1 && oorder.status == 1 && oorder.rlevel - reviewagen.level > 0"
                ng-click="reject(viewid)">驳回
        </button>
        <button type="button"
                style="margin-right: 1em;text-align: center;padding: 5px 10px;height: 30px;margin-top: 5px;border-radius: 0;width: auto"
                class="mui-btn mui-btn-danger mui-btn-outlined" ng-show="oorder.rvstatus == 2 && oorder.status != 2"
                disabled>已审核：等待厂家审核
        </button>
        <button type="button"
                style="margin-right: 1em;text-align: center;padding: 5px 10px;height: 30px;margin-top: 5px;border-radius: 0;width: auto"
                class="mui-btn mui-btn-danger mui-btn-outlined" ng-show="oorder.status == 2" disabled>已驳回
        </button>
        <button type="button"
                style="margin-right: 1em;text-align: center;padding: 5px 10px;height: 30px;margin-top: 5px;border-radius: 0;width: auto"
                class="mui-btn mui-btn-danger mui-btn-outlined" ng-show="oorder.rvstatus == 3" disabled>已完成：厂家已审核
        </button>


        <div class="mui-input-row" style="background:white">
            <button type="button"
                    style="margin-right: 1em;text-align: center;padding: 5px 10px;height: 30px;margin-top: 5px;border-radius: 0;width: auto"
                    class="mui-btn mui-btn-danger mui-btn-outlined" ng-show="oorder.rvstatus == 1"
                    ng-click="flow(viewid)">流转
            </button>
        </div>
    </div>

</div>

<include file="./Application/Home/View/pub/agentfoot.html"/>
<script>
    var app = getApp("myApp", []);

    app.controller('Ctrl', function ($scope, $http) {
        $http({
            method: 'GET',
            url: "/index.php/Home/AgentOnlineorder/agenonlineorderdetail?orderid=" + getUrlParam('orderid') + "&agen=" + getUrlParam('agen') + "&viewid=" + getUrlParam('viewid')
        }).then(function successCallback(response) {
            //console.log(response.data.data);
            if (response.data.code == -1) {
                layer.msg(response.data.msg, {time: 1500})
            } else {
                $scope.detail = response.data.data.detail;
                $scope.stock = response.data.data.agenstock;
                $scope.agen = response.data.data.agen;
                $scope.oorder = response.data.data.oorder;
                $scope.viewid = response.data.data.viewid;
                $scope.reviewagen = response.data.data.reviewagen;
            }
            $scope.floor = function (number) {
                return Math.floor(number);
            };
        }, function errorCallback(response) {
        });

        //审核
        $scope.audit = function (id) {
            layer.confirm('是否要审核？', {
                btn: ['取消', '确认'] //按钮
            }, function () {
                layer.msg('已取消');
            }, function () {
                $http({
                    method: 'POST',
                    data: {'id': id},
                    headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                    transformRequest: function (obj) {
                        var str = [];
                        for (var p in obj) {
                            str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
                        }
                        return str.join("&");
                    },
                    url: "/index.php/Home/AgentOnlineorder/auditagenreview"
                }).then(function successCallback(response) {
                    //console.log(response.data);
                    if (response.data.code == -1) {
                        layer.msg(response.data.msg, {time: 1500});
                    } else {
                        layer.msg(response.data.msg, {time: 1500});
                        setTimeout(function () {
                            window.location.href = "/index.php/Home/agen/audit"
                        }, 1500)
                    }
                }, function errorCallback(response) {
                    errorHandle(response);
                });
            })
        }

        //流转
        $scope.flow = function (id) {
            layer.confirm('是否要流转？', {
                btn: ['取消', '确认'] //按钮
            }, function () {
                layer.msg('已取消');
            }, function () {
                $http({
                    method: 'POST',
                    data: {'id': id},
                    headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                    transformRequest: function (obj) {
                        var str = [];
                        for (var p in obj) {
                            str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
                        }
                        return str.join("&");
                    },
                    url: "/index.php/Home/AgentOnlineorder/flowagenreview"
                }).then(function successCallback(response) {
                    //console.log(response.data);
                    layer.msg(response.data.msg, {time: 1500})
                    setTimeout(function () {
                        window.location.href = "/index.php/Home/agen/audit"
                    }, 1500)
                }, function errorCallback(response) {
                    errorHandle(response);
                });
            })
        }

        //驳回
        $scope.reject = function (id) {
            layer.confirm('是否要驳回？', {
                btn: ['取消', '确认'] //按钮
            }, function () {
                layer.msg('已取消');
            }, function () {
                $http({
                    method: 'POST',
                    data: {'id': id},
                    headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                    transformRequest: function (obj) {
                        var str = [];
                        for (var p in obj) {
                            str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
                        }
                        return str.join("&");
                    },
                    url: "/index.php/Home/AgentOnlineorder/rejectReview"
                }).then(function successCallback(response) {
                    //console.log(response.data);
                    if (response.data.code == -1) {
                        layer.msg(response.data.msg, {time: 1500});
                    } else {
                        layer.msg(response.data.msg, {time: 1500});
                        setTimeout(function () {
                            window.location.href = "/index.php/Home/agen/audit"
                        }, 1500)
                    }
                }, function errorCallback(response) {
                    errorHandle(response);
                });
            })
        }
    })
</script>
</body>
</html>